
import React, { Component,  } from 'react'
import PropTypes from 'prop-types'
import ReactDom, {render}  from 'react-dom'
class LoadingCom extends Component{
  _render(){
    return (  
      <div className="loading">
        <div className="loading-model">
          <div className="loading-image" >loading...</div>
        </div>
      </div>
    )
  }
  render(){
    return (
      <div>{this._render()}</div>
    )
  }
}
const load = ()=>{
  let divKey='div_loading_'
  return {
    show:()=>{
      let div = document.getElementById(divKey)
      if(!div){
        let div = document.createElement('div')
        div = document.createElement('div')
        div.id = divKey
        document.body.appendChild(div);
        render(
          <LoadingCom></LoadingCom>,div
        )
      }
    },
    hide:()=>{
      let div = document.getElementById(divKey)
      if(div){
        ReactDom.unmountComponentAtNode(div)
        document.body.removeChild(div);
      }
    }
  }
}
export default load()
